<!--
 *@开发者: 刘翔
 *@创建时间: 2024-04-26 10:33:30
 *@描述:表格
!-->
<template>
  <div
    class="form-list"
    :style="{
      '--borderColor': borderColor,
    }"
  >
    <div class="form-list-title-list" :style="{ height: topHeightValue, fontSize: fontSizeTile }">
      <div class="form-line" :style="{ width: formParameter.leftList.widthValue }">
        <div class="form-line-title" :style="{ width: item.width }" v-for="(item, index) in formParameter.leftList.titleList" :key="index">
          {{ item.title }}
        </div>
      </div>
      <div class="form-type-line-box" :style="{ width: formParameter.rightList.widthValue }">
        <div class="form-type-line" v-for="(item, index) in formParameter.rightList.titleList" :key="index">
          <div class="form-type-line-item">
            <div class="form-type-line-name">
              {{ index }}
            </div>
            <div class="form-type-line-item-box">
              <div class="form-type-line-item-name" v-for="(item1, index1) in item" :key="index1" :style="{ width: item1.width }">
                {{ item1.customTitle ? item1.customTitle : item1.title }}
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div
      class="form-list-content-list"
      :style="{
        height: bottomHeightValue,
        fontSize: fontSizeContent,
      }"
    >
      <div class="form-data-left" :style="{ width: formParameter.leftList.widthValue }">
        <div class="form-data-left-item-box" :style="{ width: item.width }" v-for="(item, index) in formParameter.leftList.titleList" :key="index">
          <div class="form-data-left-item" v-for="(findData, findIndex) in data_list" :key="findIndex">
            {{ findData[item.title] }}
          </div>
        </div>
      </div>
      <div class="form-data-right" :style="{ width: formParameter.rightList.widthValue }">
        <div class="form-data-right-type" v-for="(itemTile, index) in formParameter.rightList.titleList" :key="index">
          <div class="form-data-right-type-item-box" v-for="(dataListItem, dataListIndex) in data_list" :key="dataListIndex" :style="{ width: itemTile.width }">
            <div
              class="form-data-right-type-item"
              v-for="(title, titleIndex) in itemTile"
              :key="titleIndex"
              :style="{
                width: title.width,
                backgroundColor: title.bkColorHighlightValue ? dataListItem[title.bkColorHighlightValue] : '#fff',
              }"
            >
              {{ dataListItem[title.title] }}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  // 组件名称
  name: 'formList',
  // 组件参数 接收来自父组件的数据
  props: {
    //标题文字颜色
    topTitleFontColor: {
      type: String,
      default: '#fff',
    },
    //标题背景颜色
    topTitleBackgroundColor: {
      type: String,
      default: '#4874cb',
    },
    //边框颜色
    borderColor: {
      type: String,
      default: '#000',
    },
    //单行颜色
    lineOneColor: {
      type: String,
      default: '#fff',
    },
    //双行颜色
    lineTwoColor: {
      type: String,
      default: '#edeced',
    },
    topHeightValue: {
      type: [String, Number],
      default: '5%',
    },
    bottomHeightValue: {
      type: [String, Number],
      default: '95%',
    },
    fontSizeTile: {
      type: [String, Number],
      default: '1.3rem',
    },
    fontSizeContent: {
      type: [String, Number],
      default: '1.3rem',
    },
    formParameter: {
      type: Object,
      default: () => {
        return {};
      },
    },
    data_list: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  // 局部注册的组件
  components: {},
  // 组件状态值
  data() {
    return {};
  },
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 组件方法
  methods: {},
  created() {},
  mounted() {},
};
</script>

<style lang="less" scoped>
.form-list {
  --borderColor: #000;
  width: 100%;
  height: 100%;
  border: 1px solid var(--borderColor);
  font-size: 1.2rem;
  .form-list-title-list {
    display: flex;
    height: 5%;
    color: #fff;
    background: #4874cb;
    .form-line {
      display: flex;
      align-items: center;
      justify-content: center;
      .form-line-title {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
        width: 100%;
        border: 1px solid var(--borderColor);
      }
    }
    .form-type-line-box {
      display: flex;
      align-items: center;
      .form-type-line {
        flex: 1;
        height: 100%;
        &:nth-child(2n) {
          .form-type-line-item {
            background: #80a1e2;
          }
        }
        .form-type-line-item {
          height: 100%;
          .form-type-line-name {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 40%;
            border: 1px solid var(--borderColor);
          }
          .form-type-line-item-box {
            display: flex;
            height: 60%;
            .form-type-line-item-name {
              padding: 0 10px;
              display: flex;
              align-items: center;
              justify-content: center;
              height: 100%;
              border: 1px solid var(--borderColor);
            }
          }
        }
      }
    }
  }
  .form-list-content-list {
    display: flex;
    width: 100%;
    height: 95%;
    .form-data-left {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100%;
      .form-data-left-item-box {
        display: flex;
        flex-direction: column;
        height: 100%;
        width: 100%;
        .form-data-left-item {
          flex: 1;
          display: flex;
          align-items: center;
          justify-content: center;
          border: 1px solid var(--borderColor);
        }
      }
    }
    .form-data-right {
      display: flex;
      .form-data-right-type {
        flex: 1;
        display: flex;
        flex-direction: column;
        .form-data-right-type-item-box {
          flex: 1;
          display: flex;
          align-items: center;
          justify-content: center;
          width: 100%;
          .form-data-right-type-item {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100%;
            border: 1px solid var(--borderColor);
          }
        }
      }
    }
  }
}
</style>
